﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HousingKey.aspx.cs" Inherits="ZLDC.Estate.PM.HousingKey" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>钥匙管理</title>
    <link href="../css/main.css" rel="stylesheet" type="text/css" />

    <script src="../js/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>

    <script src="../js/LexunJS.js" type="text/javascript"></script>

    <link href="../css/PLG.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        $(document).ready(function() {
            var id = LexunJS.GetQueryString("type"); // 类型ID
            if (id == "1") {//传操作类型，判断是，借钥匙，还是还钥匙
                document.getElementById("keyUserName").innerHTML = "还钥匙人:";
            }
        });
        function AddKeyInfo() {
            var keyno = document.getElementById("txtkeyno").value;
            var tbUserName = document.getElementById("tbUserName").value;
            if (keyno == "") {
                alert("请输入钥匙编号！");
                return false;
            }
            if (tbUserName == "") {
                alert("请输入钥匙人员！");
                return false;
            }

            var id = LexunJS.GetQueryString("id");
            var kid = LexunJS.GetQueryString("kid");
            var type = LexunJS.GetQueryString("type");
            var keyno = document.getElementById("txtkeyno").value;
            var keyname = document.getElementById("tbUserName").value;
            var Operator = document.getElementById("Operator").value;
            var userid = 0;
            if (keyname != "") {
                var str = keyname.split(',');
                var username = str[0];
                var strlist = username.split('[');
                userid = strlist[1];
            }
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerHousing.ashx',
                data: 'act=p_housingKey_insert&eid=' + id + '&keyno=' + keyno + '&userid=' + userid + '&Operator=' + Operator + '&kid=' + kid,
                timeout: '10000',
                error: function() {
                    alert("修改失败！");
                },
                success: function(json) {
                    if (json == "更新成功" || json == "添加成功") {
                        window.close();
                    } else {
                        alert(json);
                    }
                }
            });
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">

    <script src="../js/jquery.autocomplete.js" type="text/javascript"></script>

    <table height="60" border="0" align="center" bgcolor="#CCCCCC" cellpadding="0" cellspacing="0">
        <tr>
            <td width="80" bgcolor="#F7F7F7">
                <span>钥匙编号：</span>
            </td>
            <td bgcolor="#FFFFFF">
                <span class="style1">
                    <input id="txtkeyno" runat="server" size="15" style="width: 150px" />
                </span>
            </td>
        </tr>
        <tr>
            <td bgcolor="#F7F7F7" style="width: 80px">
                <span id="keyUserName">借钥匙人：</span>
            </td>
            <td bgcolor="#FFFFFF">
                <span class="style1">
                    <input id="tbUserName" name="tbUserName" size="15" maxlength="15" style="width: 150px" />
                </span>
            </td>
        </tr>
    </table>
    <div id="tabbottom" style="text-align: right;">
        <input id="btnOk" class="button_bak" type="button" value="确定" onclick="AddKeyInfo()" />
        <input id="btnReturn" class="button_bak" type="button" value="返回" onclick="window.close();" />
    </div>
    </div>
    <input id="Operator" runat="server" type="hidden" />
    </form>
    <div align="center">
    </div>

    <script language="javascript" type="text/javascript">
        $(document).ready(function() {
            $("#tbUserName").autocomplete("../Ajax/GetUserAuto.aspx", { minChars: 2, extraParams: { uname: function() { return escape($('#tbUserName').val()); } }, scrollHeight: 350, width: 180, max: 100 });
            document.getElementById("tbUserName").focus();
        });
    </script>

</body>
</html>
